﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.Reporting.WebForms;
using Anke.SHManage.MSSQLDAL;
using Anke.SHManage.BLL;

namespace Anke.SHManage.Web.Reports
{
    public partial class LS_WZXXWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (UserOperateContext.Current.Session_UsrInfo == null) //add2023-08-07 plq
            {
                Response.Redirect("~/Home/RedirectToLogin");
            }
            else if (!IsPostBack)
            {
                InitPage();
            }
        }
         private void InitPage()
        {
            this.Time.Text = DateTime.Now.AddDays(+1).ToString("yyyy-MM-dd 00:00:00");
            BindReportDataSource();
           
        }

        protected void btnsearch_click(object sender, EventArgs e)
        {
            BindReportDataSource();
            this.Material.Text = "";
        }
       
        protected void BindReportDataSource()
        {
            string ck = Convert.ToString(this.Storage.Text);  
            string fl = Convert.ToString(this.MaterialType.Text);
            string wz = Convert.ToString(this.Material.Text);
            string time = Convert.ToString(this.Time.Text);
            List<int> StroageIDs = new List<int>();
            StroageIDs = UserOperateContext.Current.Session_StorageRelated.listUserStorage;
            string instr = "";
            foreach (int item in StroageIDs)
            {
                instr += "'" + item + " ',";
            }
            instr = instr.Substring(0, instr.Length - 1);
            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/LS_WZXX.rdlc");
           
           
            LSDAL dal = new LSDAL();
            DataTable dt = dal.Get_LS_WZXX(instr,ck,fl,wz,time);
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetWZXXLS", dt));

            this.ReportViewer1.LocalReport.Refresh();
        }


    }
}